<?php
require_once '../utils/common.php';
checkUserValidate ();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>管理系统</title>
<link href="../CSS/form.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../ckeditor/ckeditor.js"></script>
<script type="text/javascript" src="../js/jquery-1.10.1.js"></script>

<link href="../umeditor/themes/default/css/umeditor.css" type="text/css"
	rel="stylesheet">
	<script type="text/javascript"
		src="../umeditor/third-party/jquery.min.js"></script>
	<script type="text/javascript" charset="utf-8"
		src="../umeditor/umeditor.config.js"></script>
	<script type="text/javascript" charset="utf-8"
		src="../umeditor/umeditor.min.js"></script>
	<script type="text/javascript" src="../umeditor/lang/zh-cn/zh-cn.js"></script>


<script type="text/javascript">
	$(function(){
		
	})
</script>
</head>

<body>
	<fieldset>
		<legend>添加</legend>
		<form id="addForm" action="XuexiProcess.php" method="post"
			class="form" enctype="multipart/form-data">
			<input type="hidden" name="flag" value="add" />
			<ul>
				<li><label>标题:</label></li>
				<li><input type="text" name="title" id="title" class="txt" /></li>
				<li><label>内容:</label></li>
				<!-- <li><textarea name="content" id="content" class="ckeditor"/></li> -->
				<script type="text/plain" id="content" name="content"
					style="width:1000px;height:240px;">
</script>

				<li><input type="submit" value="添加" class="btn" /></li>
			</ul>
		</form>
	</fieldset>
	<script type="text/javascript">
    //实例化编辑器
    var um = UM.getEditor('content');
    um.addListener('blur',function(){
        $('#focush2').html('编辑器失去焦点了')
    });
    um.addListener('focus',function(){
        $('#focush2').html('')
    });
    //按钮的操作
    function insertHtml() {
        var value = prompt('插入html代码', '');
        um.execCommand('insertHtml', value)
    }
    function isFocus(){
        alert(um.isFocus())
    }
    function doBlur(){
        um.blur()
    }
    function createEditor() {
        enableBtn();
        um = UM.getEditor('content');
    }
    function getAllHtml() {
        alert(UM.getEditor('content').getAllHtml())
    }
    function getContent() {
        var arr = [];
        arr.push("使用editor.getContent()方法可以获得编辑器的内容");
        arr.push("内容为：");
        arr.push(UM.getEditor('content').getContent());
        alert(arr.join("\n"));
    }
    function getPlainTxt() {
        var arr = [];
        arr.push("使用editor.getPlainTxt()方法可以获得编辑器的带格式的纯文本内容");
        arr.push("内容为：");
        arr.push(UM.getEditor('content').getPlainTxt());
        alert(arr.join('\n'))
    }
    function setContent(isAppendTo) {
        var arr = [];
        arr.push("使用editor.setContent('欢迎使用umeditor')方法可以设置编辑器的内容");
        UM.getEditor('content').setContent('欢迎使用umeditor', isAppendTo);
        alert(arr.join("\n"));
    }
    function setDisabled() {
        UM.getEditor('content').setDisabled('fullscreen');
        disableBtn("enable");
    }

    function setEnabled() {
        UM.getEditor('content').setEnabled();
        enableBtn();
    }

    function getText() {
        //当你点击按钮时编辑区域已经失去了焦点，如果直接用getText将不会得到内容，所以要在选回来，然后取得内容
        var range = UM.getEditor('content').selection.getRange();
        range.select();
        var txt = UM.getEditor('content').selection.getText();
        alert(txt)
    }

    function getContentTxt() {
        var arr = [];
        arr.push("使用editor.getContentTxt()方法可以获得编辑器的纯文本内容");
        arr.push("编辑器的纯文本内容为：");
        arr.push(UM.getEditor('content').getContentTxt());
        alert(arr.join("\n"));
    }
    function hasContent() {
        var arr = [];
        arr.push("使用editor.hasContents()方法判断编辑器里是否有内容");
        arr.push("判断结果为：");
        arr.push(UM.getEditor('content').hasContents());
        alert(arr.join("\n"));
    }
    function setFocus() {
        UM.getEditor('content').focus();
    }
    function deleteEditor() {
        disableBtn();
        UM.getEditor('content').destroy();
    }
    function disableBtn(str) {
        var div = document.getElementById('btns');
        var btns = domUtils.getElementsByTagName(div, "button");
        for (var i = 0, btn; btn = btns[i++];) {
            if (btn.id == str) {
                domUtils.removeAttributes(btn, ["disabled"]);
            } else {
                btn.setAttribute("disabled", "true");
            }
        }
    }
    function enableBtn() {
        var div = document.getElementById('btns');
        var btns = domUtils.getElementsByTagName(div, "button");
        for (var i = 0, btn; btn = btns[i++];) {
            domUtils.removeAttributes(btn, ["disabled"]);
        }
    }
</script>

</body>

</html>